//
//  TitleButton.swift
//  JGWB
//
//  Created by 付建国 on 2016/10/9.
//  Copyright © 2016年 sher. All rights reserved.
//

import UIKit

class TitleButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setTitleColor(UIColor.black, for: .normal)
        setImage(UIImage.init(named: "navigationbar_arrow_down"), for: .normal)
        setImage(UIImage.init(named: "navigationbar_arrow_up"), for: .selected)
        sizeToFit()
    }
    
    //swift中规定：重新控件的init(frame)方法或者init方法必须重写下面这个方法
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        titleLabel!.frame.origin.x = 0
        titleLabel?.font = UIFont.systemFont(ofSize: 15)
        imageView!.frame.origin.x = titleLabel!.frame.size.width + 7
        
    }
  
}
